package common.utils;




import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;

public class IOUtils {
	private IOUtils(){}
	public static void in2out(InputStream in,  OutputStream out) throws IOException {
		byte[] bys = new byte[1024*16];
		int len = 0;
	
		while((len =in.read(bys))!=-1){
			
			out.write(bys, 0, len);
			
		}
//		close(out);
//		close(in);

	}
	public static void close(InputStream in){
		if (in!=null) {
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}finally{
				in=null;
			}
			
		}
	}
	public static void close(Writer writer){
		if (writer!=null) {
			try {
				writer.close();
			} catch (IOException e) {
				e.printStackTrace();
			}finally{
				writer=null;
			}
			
		}
	}

	public static void close(Reader reader){
		if (reader!=null) {
			try {
				reader.close();
			} catch (IOException e) {
				e.printStackTrace();
			}finally{
				reader=null;
			}

		}
	}
	public static void close(OutputStream out) {
		if (out!=null) {
			try {
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}finally{
				out=null;
			}
			
		}
	}

}
